package org.wsjy.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wsjy.mapper.TDeviceMapper;
import org.wsjy.model.TDevice;
import org.wsjy.util.DateUtil;

/**
 * 
 * @Title:
 * @Company:万世极缘工作室
 * @Description:
 * @Author:万世极缘
 * @Since:2016年2月2日
 * @Copyright:Copyright (c) 2016
 * @ModifyDate:
 * @Version:1.1.0
 */
@Service
public class DeviceService {
    @Autowired
    private TDeviceMapper deviceMapper;

    /**
     * 创建设备数据
     * 
     * @param device
     * @return
     * @Description:
     */
    public int add(TDevice device) {
        device.setStId(UUID.randomUUID().toString());// 随机ID
        device.setDtCreateTime(DateUtil.getNow());
        return deviceMapper.insert(device);
    }

    /**
     * 修改设备数据
     * 
     * @param device
     * @return
     * @Description:
     */
    public int update(TDevice device) {
        device.setDtUpdateTime(DateUtil.getNow());
        return deviceMapper.updateByPrimaryKey(device);
    }

    /**
     * 删除设备数据
     * 
     * @param device
     * @return
     * @Description:
     */
    public int delete(TDevice device) {
        return deviceMapper.deleteByPrimaryKey(device.getStId());
    }

    /**
     * 查询所有的设备信息
     * 
     * @return
     * @Description:
     */
    public List<TDevice> findAll() {
        return deviceMapper.findAll();
    }


}
